package br.gov.serpro.curso.projeto.wishilist.servicos;

import android.app.IntentService;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationCompat.Builder;
import android.util.Log;
import br.gov.serpro.curso.projeto.wishlist.R;

public class Servico extends IntentService {

	public Servico() {
		super("Servico Toast");
		Log.i("TAG_SERV", "Criou o serviço Servico Toast");
	}

	
	public Servico(String name) {
		super(name);
	}

	@Override
	protected void onHandleIntent(Intent intent) {
		Log.i("SERV", "LOG DO SERVICO "+intent.getExtras().getString("preco"));
		
		try {
			Thread.sleep(1000 * 10);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}		
		
		final NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
		
		NotificationCompat.Builder builder = new Builder(this);
		builder.setWhen(System.currentTimeMillis());
		builder.setSmallIcon(R.drawable.ic_launcher);
		builder.setTicker("Olha a Faaaaca!");
		builder.setContentTitle("Content Title");
		builder.setContentText(intent.getExtras().getString("preco"));
		builder.setContentInfo("Content Info");
		builder.setVibrate(new long[] { 0, 100, 100, 200, 100, 200 });
		builder.setLights(0xff00ff00, 300, 100);

	//	Intent i = new Intent(this, Main2Activity.class);

	//	PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, i, 0);
	//	builder.setContentIntent(pendingIntent);
		
		notificationManager.notify(1, builder.build());
		
	}

}
